package com.fjjn.controller;

import com.fjjn.component.RedissionDelayQueueService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * 测试redisson延迟队列
 */
@Slf4j
@RestController
@ConditionalOnBean(RedissionDelayQueueService.class)
public class RedisDelayQueueController {


    @Resource
    private  RedissionDelayQueueService redissionDelayQueueService;


    @RequestMapping("/add")
    public String add2Queue(){
        for (long i = 0; i < 20; i++) {
            redissionDelayQueueService.addDelayQueue(i,10, TimeUnit.SECONDS,"PAY_CALLBACK");
        }
        return "ok";
    }
}
